#!/bin/bash
set -e

TMP=${TMP:-/tmp/work}
LOG=${LOG:-$HOME/logs/stage1}
SRC=${SRC:-$LFS/sources}

name=binutils-pass1
version=2.36.1

rm -fr $TMP
mkdir -pv $TMP $LOG

tar xf $SRC/binutils-$version.tar.xz -C $TMP

{ time \
   {
    
    cd $TMP/binutils-$version
    
    mkdir -v build
    cd       build

    ../configure --prefix=$LFS/tools       \
                --with-sysroot=$LFS        \
                --target=$LFS_TGT          \
                --disable-nls              \
                --disable-werror
                
    make
    
    make install

    }
} 2>&1 | tee $name.log

[ $PIPESTATUS = 0 ] && mv $name.log $LOG || exit $PIPESTATUS

rm -fr $TMP
